Skip to content

Rust: Make impl blocks only give rise to direct trait implementation#20723

Merged
hvitved merged 4 commits intogithub:mainfrom
paldepind:rust/ti-inheritance
Nov 17, 2025
Merged

Rust: Make impl blocks only give rise to direct trait implementation#20723
hvitved merged 4 commits intogithub:mainfrom
paldepind:rust/ti-inheritance

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Oct 30, 2025

This PR changes how we calculate the trait/implements hierarchy.

Currently an impl Trait for T block makes T directly implement both Trait and any supertraits, SuperTrait, of Trait. However, in order for this impl block to be valid, it must already be the case that T implements SuperTrait by some other impl block. Hence, the only new information from an impl block is the implementation of the specific target trait.

This PR changes how we handle impl blocks when calculating the trait/implements hierarchy, s.t. impl blocks only makes a type implement the specific trait in the impl block.

This restriction is also used in AssocFunctionType where the restriction removes some spurious call targets.

The DCA report shows a small speedup and decent reductions in "Path resolution inconsistencies" and "Nodes With Type At Length Limit". There is a small increase in "Unknown expression types". I think this increase looks reasonable when compared to the decrease in "Path resolution inconsistencies". I also did a quick and small spot check on neon, and the lost types all looked like spurious types.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants